/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tcloudclient.fileSystem;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 *
 * @author Tomas
 */
public class FileNodeUtil {

    private static Comparator<FileNode> comparator = new Comparator<FileNode>() {

        @Override
        public int compare(FileNode o1, FileNode o2) {
            if (o1.isLeaf() && !o2.isLeaf()) {
                return 1;
            } else if (!o1.isLeaf() && o2.isLeaf()) {
                return -1;
            } else {
                return o1.getName().compareToIgnoreCase(o2.getName());
            }
        }
    };

    public static void sort(List<FileNode> nodes) {
        Collections.sort(nodes, comparator);
    }
}
